package com.google.android.gms.internal;

import android.support.annotation.NonNull;
import com.google.android.gms.common.api.OptionalPendingResult;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.Result;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.ResultTransform;
import com.google.android.gms.common.api.TransformedResult;
import java.util.concurrent.TimeUnit;

public final class zzabk<R extends Result> extends OptionalPendingResult<R> {
    private final zzaaf<R> zzaDb;

    public zzabk(PendingResult<R> pendingResult) {
        if (!(pendingResult instanceof zzaaf)) {
            throw new IllegalArgumentException("OptionalPendingResult can only wrap PendingResults generated by an API call.");
        }
        this.zzaDb = (zzaaf) pendingResult;
    }

    public R await() {
        return this.zzaDb.await();
    }

    public R await(long j, TimeUnit timeUnit) {
        return this.zzaDb.await(j, timeUnit);
    }

    public void cancel() {
        this.zzaDb.cancel();
    }

    public R get() {
        if (isDone()) {
            return await(0, TimeUnit.MILLISECONDS);
        }
        throw new IllegalStateException("Result is not available. Check that isDone() returns true before calling get().");
    }

    public boolean isCanceled() {
        return this.zzaDb.isCanceled();
    }

    public boolean isDone() {
        return this.zzaDb.isReady();
    }

    public void setResultCallback(ResultCallback<? super R> resultCallback) {
        this.zzaDb.setResultCallback(resultCallback);
    }

    public void setResultCallback(ResultCallback<? super R> resultCallback, long j, TimeUnit timeUnit) {
        this.zzaDb.setResultCallback(resultCallback, j, timeUnit);
    }

    @NonNull
    public <S extends Result> TransformedResult<S> then(@NonNull ResultTransform<? super R, ? extends S> resultTransform) {
        return this.zzaDb.then(resultTransform);
    }

    public void zza(zza zza) {
        this.zzaDb.zza(zza);
    }

    public Integer zzvr() {
        return this.zzaDb.zzvr();
    }
}
